<template>
  <el-form :model="form">
    <el-form-item label="姓名">
      <el-input type="text" autocomplete="off" v-model="form.perName" />
    </el-form-item>
    <el-form-item label="类型">
      <el-select v-model="form.type" placeholder="选择类型">
        <el-option
          v-for="(item, index) in types" 
          :key="index" 
          :label="item" 
          :value="item"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="排序">
      <el-input type="number" v-model="form.sort" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="add">
        保存
      </el-button>
      <el-button @click="cancel">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive } from 'vue';
import request from '@/api/request';

const form = reactive({
  perName: '',
  type: '',
  sort: ''
});
const types = ['业务员', '财务员'];

const add = async () => {
  
    request.post('/basic/person/add', {
      perName: form.perName,
      type: form.type,
      sort: form.sort,
      status: 1, // 或者根据需要设置
      tenantId: 63 // 或者根据需要设置
    }, {
      headers: {
        'Content-Type': 'application/json'
      }
    });
 
};


const resetForm = () => {
  form.perName = '';
  form.type = '';
  form.sort = '';
};

// 取消操作（可以选择重置表单或其他逻辑）
const cancel = () => {
  resetForm();
};
</script>

<style scoped>
/* 可以根据需要添加样式 */
</style>
